package com.spic.business.informatization.befor_work_sign.controller;

import com.spic.business.informatization.befor_work_sign.domain.MeetingBeforeSignSubtable;
import com.spic.business.informatization.befor_work_sign.service.IMeetingBeforeSignSubtableService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 班前会签到人员Controller
 *
 * @author yangjie
 * @date 2021-12-20
 */
@RestController
@RequestMapping("/informatization/before_after_work_sign")
public class MeetingBeforeSignSubtableController extends BaseController
{
    @Autowired
    private IMeetingBeforeSignSubtableService meetingBeforeSignSubtableService;

    /**
     * 查询班前会签到人员列表
     */
//    @PreAuthorize(hasPermi = "business/informatization:before_after_work_sign:list")
    @GetMapping("/list")
    public TableDataInfo list(MeetingBeforeSignSubtable meetingBeforeSignSubtable)
    {
        startPage();
        List<MeetingBeforeSignSubtable> list = meetingBeforeSignSubtableService.selectMeetingBeforeSignSubtableList(meetingBeforeSignSubtable);
        return getDataTable(list);
    }

    /**
     * 导出班前会签到人员列表
     */
//    @PreAuthorize(hasPermi = "business/informatization:before_after_work_sign:export")
    @Log(title = "班前会签到人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeetingBeforeSignSubtable meetingBeforeSignSubtable) throws IOException
    {
        List<MeetingBeforeSignSubtable> list = meetingBeforeSignSubtableService.selectMeetingBeforeSignSubtableList(meetingBeforeSignSubtable);
        ExcelUtil<MeetingBeforeSignSubtable> util = new ExcelUtil<MeetingBeforeSignSubtable>(MeetingBeforeSignSubtable.class);
        util.exportExcel(response, list, "班前会签到人员数据");
    }

    /**
     * 获取班前会签到人员详细信息
     */
//    @PreAuthorize(hasPermi = "business/informatization:before_after_work_sign:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(meetingBeforeSignSubtableService.selectMeetingBeforeSignSubtableById(id));
    }

    /**
     * 新增班前会签到人员
     */
//    @PreAuthorize(hasPermi = "business/informatization:before_after_work_sign:add")
    @Log(title = "班前会签到人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeetingBeforeSignSubtable meetingBeforeSignSubtable)
    {
        return toAjax(meetingBeforeSignSubtableService.insertMeetingBeforeSignSubtable(meetingBeforeSignSubtable));
    }

    /**
     * 修改班前会签到人员
     */
//    @PreAuthorize(hasPermi = "business/informatization:before_after_work_sign:edit")
    @Log(title = "班前会签到人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeetingBeforeSignSubtable meetingBeforeSignSubtable)
    {
        return toAjax(meetingBeforeSignSubtableService.updateMeetingBeforeSignSubtable(meetingBeforeSignSubtable));
    }

    /**
     * 删除班前会签到人员
     */
//    @PreAuthorize(hasPermi = "business/informatization:before_after_work_sign:remove")
    @Log(title = "班前会签到人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(meetingBeforeSignSubtableService.deleteMeetingBeforeSignSubtableByIds(ids));
    }
}
